package data;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * @deprecated
 */
public class DataElement implements Serializable {

	private static final long serialVersionUID = -3189613389300564522L;

	public enum DataElementType {
		COMPLEX, INT, FLOAT, BOOL, STRING
	}

	private String name;
	private DataElementType type;
	private Object value;
	private ArrayList<DataElement> childElements;

	public DataElement(String name, DataElementType type, Object value) {
		super();
		this.name = name;
		this.type = type;
		this.value = value;
		this.childElements = new ArrayList<DataElement>();
	}

	public void addChildElement(DataElement de) {
		if (de != null) {
			childElements.add(de);
		}
	}

	public String getName() {
		return name;
	}

	public DataElementType getType() {
		return type;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(Object value) {
		if (value != null) {
			this.value = value;
		}
	}

	public DataElement getChildElementOfName(String name) {
		for (DataElement de : childElements) {
			if (de.getName().equals(name)) {
				return de;
			}
		}
		return null;
	}

	public ArrayList<DataElement> getAllElementsOfName(String name) {
		ArrayList<DataElement> elements = new ArrayList<DataElement>();
		for (DataElement de : childElements) {
			if (de.getName().equals(name)) {
				elements.add(de);
			}
		}
		return elements;
	}

}
